package lesson02;


public class Demo_204 {
    //public static boolean isQuit = false;  用标记位处理中断
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("我在转账。。。");
            }
            System.out.println("转账结束。。");
        });
        thread.start();
        System.out.println("线程是否存活" + thread.isAlive());
        Thread.sleep(100);
        System.out.println("线程是否存活" + thread.isAlive());
        //中断线程
        System.out.println("骗子不转了");
        thread.interrupt();
        //System.out.println("状态"+ thread.getState());
        Thread.sleep(1000);
        System.out.println("线程是否存活" + thread.isAlive());
        System.out.println();
    }
}
